<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>更新地点</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<!-- Add by Kravis Liu 2014.09.22 -->
		<link rel="stylesheet" href="/css/base.css" />
		<link rel="stylesheet" href="/css/form.css" />
		<link rel="stylesheet" media="screen" href="/css/validate.css">
		<script src="/js/av-mini.js"></script>
		<script src="/js/av.js"></script>
		<script src="/js/jquery-1.11.1.min.js"></script>
		<script src="/js/load.js"></script>
		<script src="/js/jqueryValidation/jquery.validate.min.js"></script>	
		<script src="/js/jqueryValidation/additional-methods.js"></script>
		<script src="/js/myTime.js"></script>		
		<script type="text/javascript">
			$(document).ready(function(){
	        
			        $("#updateTaskForm").validate({
					rules: {
						mylocation: {
							required: true
						},
					},
					messages: {
						mylocation: {
							required: "任务标题不能为空！"
						},
					},
					submitHandler:function(form){
		                form.submit();
		            }
				});
			        
			        
			    });
			    
			function upload(){
				$("#updateTaskForm").submit();

			}
			
			function getLocation(){
				window.open("http://lbs.amap.com/console/show/picker");
			}
			
			function showImg(fileid) {  
				var reader = new FileReader();  
				var picpreview=document.getElementById("preview");    
				reader.onload = function(e) {  
					var img = $("#taskImg");
					img.attr("src",this.result); 
				}
				reader.readAsDataURL(document.getElementById(fileid).files[0]);  
			}

		</script>
	</head>

	<body>
	        <div id="page">

			<div id="header">
				<h4>地点管理</h4>
			</div>
	
			<form enctype="multipart/form-data" method="post" id="updateTaskForm" action="/app/updateLocation">	
			<%if(LocationObject){%>
				<input type="hidden" name="locationId" id="locationId" value="<%=LocationObject.id%>"/>
				<div id="div_1">
					<p>
						<label>推荐地：</label>
						<input type="text" name="mylocation" id="mylocation" value="<%=LocationObject.get('locationName')%>"/>
					</p>
					<p>
					  	<label>所属国家：</label>
					  	<select name="country" id="country">
						<%if(CountryResults){%>
							<%  CountryResults.forEach(function (countryObject){ %>
								<option value='<%= countryObject.id %>' <%if(countryObject.id == LocationObject.get('country').id){%> selected='selected'<%}%>><%= countryObject.get('nameCN') %></option>

						<% })} %>  
				  		</select>
					</p>
					<p>
					<p>
						<label>所属地区：</label>
							<input type="text" name="district" id="district" value="<%=LocationObject.get('district')%>"/>
					</p>		
					<p>
					<label>简介：</label>
					<textarea id="briefing" name="briefing" rows="3" cols="50" ><%=LocationObject.get('briefing')%></textarea>
					</p>		

					<p>
						<label>任务图片：</label>
						
						<img id="taskImg" src="<%= imageFileSrc %>" style="width: 350px; height: 200px;"/>
						</p>
						<input type="file" id="imageFile" name="imageFile" onchange="showImg(this.id);">
					
					</p>
				
					<p>
					  	<label>地理位置：</label>
					 	<input type="button" name="location" id="location" value="从地图上拾取坐标" onclick="getLocation();"/>
					</p>
					
					<% if (GeoPoint) {%>
					<p>
					  	<label>经度：</label>
					  	<input type="text" name="longitude" id="longitude" value="<%=GeoPoint.longitude%>"/>
					</p>        
					<p>
						<label>纬度：</label>
				      		<input type="text" name="latitude" id="latitude" value="<%=GeoPoint.latitude%>"/>
				      
					</p>
					<%} else {%>
                                        <p>
					  	<label>经度：</label>
					  	<input type="text" name="longitude" id="longitude" />
					</p>        
					<p>
						<label>纬度：</label>
				      		<input type="text" name="latitude" id="latitude" />
					</p>
					<%}%>
					<p>
						<label>开始时间：</label>
					 	<input id="startTime" name="startTime" value="<%= LocationObject.get('startTime')%>" type="text" onclick="setday(this,10,0);" readonly="readonly"/>
					</p>		
					<p>
						<label>截止时间：</label>
					  	<input id="endTime" name="endTime" value="<%= LocationObject.get('endTime')%>" type="text" onclick="setday(this,10,0);" readonly="readonly"/>
					</p>
					<p>
				  	<label>是否推荐：</label>
					<select name="recommend" id="recommend">
					  
						<% if (LocationObject.get('recommend') == "1") {%>
						    <option value="0">否</option>
						    <option value="1" selected>是</option>			
						<%} else {%>
						    <option value="0" selected>否</option>
						    <option value="1">是</option>		
						<%}%>
					</select>
					</p>

					<p>	
						<button class="change"  onclick="upload();">修改</button>
					</p>
				</div>		
				<%}%>
			</form>
			
			<div id="footer">
				<a style="float:right;margin:5px" href="/logout">退出</a>
				<a style="float:right;margin:5px" href="/app/index">主页</a>
			</div>
		</div>
	</body>
</html>
